/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.utilities;

import com.entities.Parameter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Min Tun
 */
public class DBUtil {

    public static void main (String[] args){
        
    }

    /**
     * Get connection to database.
     *
     * @return Connection of database.
     */
    public static Connection getConnection() {
        Connection con = null;
        ResourceBundle db = ResourceBundle.getBundle("dbconfig");

        String driver = db.getString("driver");
        String url = db.getString("connectionurl");
        String user = db.getString("username");
        String password = db.getString("password");
        try {
            Class.forName(driver);
            try {
                con = DriverManager.getConnection(url, user, password);
            } catch (SQLException ex) {
                Logger.getLogger(DBUtil.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DBUtil.class.getName()).log(Level.SEVERE, null, ex);
        }
        return con;
    }

    public int insert(String query, ArrayList<Parameter> params){
        int result = 0;
        
        return result;
    }

}
